const puppeteer = require("puppeteer");
const { segment } = require("koishi-core");
module.exports = {
  name: "查询出刀情况 [message]",
  callback: async ({ session }, message) => {
    const browser = await puppeteer.launch({
      args: ["--no-sandbox", "--disable-setuid-sandbox"],
    }); //打开浏览器
    const page = await browser.newPage(); //新建标签页
    await page.goto("http://localhost:8080/gethz"); //跳转指定页面
    let table = await page.$("table");
    const screenshot = await table.screenshot();
    await browser.close(); //关闭浏览器
    await session.send(
      segment("image", { url: "base64://" + screenshot.toString("base64") })
    );
  },
};
